export function setSectionArticleStyle() {

    "use strict";
    /*=========================================================================
        Preloader
    =========================================================================*/
    $("#preloader").delay(350).fadeOut('slow');

    /*=========================================================================
        Custom Scrollbar
    =========================================================================*/
    $(".header-inner").mCustomScrollbar();

    /*=========================================================================
     Isotope
     =========================================================================*/
    $('.portfolio-filter').on('click', 'li', function () {
        var filterValue = $(this).attr('data-filter');

        $container.isotope({filter: filterValue});
    });

    // change is-checked class on buttons
    $('.portfolio-filter').each(function (i, buttonGroup) {
        var $buttonGroup = $(buttonGroup);
        $buttonGroup.on('click', 'li', function () {
            $buttonGroup.find('.current').removeClass('current');
            $(this).addClass('current');
        });
    });

    var $container = $('.portfolio-wrapper');
    // $container.imagesLoaded( function() {
    //   $('.portfolio-wrapper').isotope({
    //       // options
    //       itemSelector: '[class*="col-"]',
    //       percentPosition: true,
    //       masonry: {
    //           // use element for option
    //           columnWidth: '[class*="col-"]'
    //       }
    //   });
    // });

    /*=========================================================================
     Infinite Scroll
     =========================================================================*/
    var curPage = 1;
    var pagesNum = $(".portfolio-pagination").find("li a:last").text();   // Number of pages

    $container.infinitescroll({
            itemSelector: '.grid-item',
            nextSelector: '.portfolio-pagination li a',
            navSelector: '.portfolio-pagination',
            extraScrollPx: 0,
            bufferPx: 0,
            maxPage: 2,
            loading: {
                finishedMsg: "No more works",
                msgText: '',
                speed: 'slow',
                selector: '.load-more',
            },
        },
        // trigger Masonry as a callback
        function (newElements) {

            var $newElems = $(newElements);
            $newElems.imagesLoaded(function () {
                $newElems.animate({opacity: 1});
                $container.isotope('appended', $newElems);
            });

            // Check last page
            curPage++;
            if (curPage === pagesNum) {
                $('.load-more').remove();
            }

        }
    );

    $container.infinitescroll('unbind');

    $('.load-more .btn').on('click', function () {
        $container.infinitescroll('retrieve');
        // display loading icon
        $('.load-more .btn i').css('display', 'inline-block');
        $('.load-more .btn i').addClass('fa-spin');

        $(document).ajaxStop(function () {
            setTimeout(function () {
                // hide loading icon
                $('.load-more .btn i').hide();
            }, 1000);
        });
        return false;
    });

    /* ======= Mobile Filter ======= */

    // bind filter on select change
    $('.portfolio-filter-mobile').on('change', function () {
        // get filter value from option value
        var filterValue = this.value;
        // use filterFn if matches value
        filterValue = filterFns[filterValue] || filterValue;
        $container.isotope({filter: filterValue});
    });

    var filterFns = {
        // show if number is greater than 50
        numberGreaterThan50: function () {
            var number = $(this).find('.number').text();
            return parseInt(number, 10) > 50;
        },
        // show if name ends with -ium
        ium: function () {
            var name = $(this).find('.name').text();
            return name.match(/ium$/);
        }
    };
}